Return * for n number of times


Posted by Christy on 2022-04-19

Description: Write a function that accepts a number n and returns * for n number of times

function star(n) {

}

console.log(star(3)); // ***
function star(n) {
  let result = "";
  for (let i = 1; i <= n; i++) {
    result += "*";
  }
  return result;
}

console.log(star(3));

Be careful about the way of ouput, if it's print -> console.log; if it's return -> return










Related Posts

[Data] 介紹一個好用的產生假資料網站

[Data] 介紹一個好用的產生假資料網站

[Day 2] JS in Pipeline (2): Docker and Local Development Environment (2)

[Day 2] JS in Pipeline (2): Docker and Local Development Environment (2)

如何打包 CRA 專案並建立不透過第三方服務即可供別人使用的專案

如何打包 CRA 專案並建立不透過第三方服務即可供別人使用的專案


Comments